package utils.base
{
	import flash.geom.Matrix3D;
	import flash.geom.Vector3D;
	
	import utils.math.Quaternion;

	public class Weight
	{
		public var jointIndex:int;
		public var pos:Vector3D;
		public var bias:Number;
		public var resultVector3D:Vector3D;
		
		private var _joint:Joint;
		private var _wv:Vector3D;
		public function Weight(jointIn:int,biasIn:Number,posIn:Vector3D)
		{
			this.jointIndex = jointIn;
			this.pos = posIn;
			this.bias = biasIn;
		}
		public function setResult(jointAry:Vector.<Joint>):void{
			var quaternion:Quaternion = new Quaternion();
			_joint = jointAry[jointIndex];
			resultVector3D = new Vector3D();
			_wv = quaternion.quaternionRotate(_joint.orient,pos);
			resultVector3D.x = (_joint.pos.x + _wv.x)*bias;
			resultVector3D.y = (_joint.pos.y + _wv.y)*bias;
			resultVector3D.z = (_joint.pos.z + _wv.z)*bias;
			/*trace(resultVector3D.x,resultVector3D.y,resultVector3D.z);
			trace("*******");
			var matrix:Matrix3D = new Matrix3D
			_joint.orient.toMatrix3D(matrix);
			matrix.appendTranslation(_joint.pos.x,_joint.pos.y,_joint.pos.z);
			
			var newv:Vector3D = matrix.transformVector(pos);
			trace(newv.x*bias,newv.y*bias,newv.z*bias)*/
			
		}
	}
}